home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / ScriptExplorer / CLG_CharInfo.cp < prev    next >
Encoding:
Text File  |  1997-07-24  |  3.7 KB  |  175 lines  |  [TEXT/CWIE]

  1. // CLG_CharInfo.cp
  2. //
  3. //        Pane subClass to display character information
  4. //
  5. //****************************************************************************
  6.  
  7. #ifdef PowerPlant_PCH
  8. #include PowerPlant_PCH
  9. #endif
  10.  
  11. // system headers
  12. #include <Script.h>
  13.  
  14. // PowerPlant headers
  15. #include <LStream.h>
  16. #include <UDrawingState.h>
  17.  
  18. // project headers
  19. #include "LG_Constants.h"
  20. #include "CLG_CharInfo.h"
  21.  
  22.  
  23. //****************************************************************************
  24. #define kVOffset    12
  25.  
  26.  
  27. //***********************
  28. //    CreateDisplayStream
  29. //****************************************************************************
  30. CLG_CharInfo*
  31. CLG_CharInfo::CreateDisplayStream(
  32.     LStream    *inStream)
  33. {
  34.     return (new CLG_CharInfo(inStream));
  35. }
  36.  
  37.  
  38. //***********************
  39. //    CLG_CharInfo
  40. //****************************************************************************
  41. CLG_CharInfo::CLG_CharInfo(void)
  42. {
  43.     this->Init();
  44.     return;
  45. }
  46.  
  47. //***********************
  48. //    CLG_CharInfo
  49. //****************************************************************************
  50. CLG_CharInfo::CLG_CharInfo( LStream *inStream)
  51.     : LPane( inStream)
  52. {
  53.     this->Init();
  54.     return;
  55. }
  56.  
  57. //***********************
  58. //    Init
  59. //****************************************************************************
  60. void CLG_CharInfo::Init(void)
  61. {
  62.     mCharNum = 0;
  63.     mBaseCharStr[0] = 1;
  64.     mBaseCharStr[1] = '0';
  65.     mHexStr[0]=0;
  66.     mDecStr[0]=0;
  67.     
  68.     return;
  69. }
  70.  
  71.  
  72. //***********************
  73. //    ClickSelf
  74. //****************************************************************************
  75. void
  76. CLG_CharInfo::ClickSelf( const SMouseDownEvent &inMouseDown)
  77. {
  78.     InvalRect( &qd.thePort->portRect);
  79.     return;
  80. }
  81.  
  82.  
  83.  
  84. //***********************
  85. //    AdjustCursorSelf
  86. //****************************************************************************
  87. void
  88. CLG_CharInfo::AdjustCursorSelf(
  89.     Point                inPortPt ,
  90.     const EventRecord&    inMacEvent)
  91. {
  92.     Point    tPt;
  93.     static Rect savR = {0,0,0,0};
  94.  
  95.     tPt = inPortPt;
  96.     
  97.     CursHandle    theCursH = ::GetCursor( 2);
  98.     if (theCursH != nil) {
  99.         ::SetCursor(*theCursH);
  100.     }
  101. }
  102.  
  103.  
  104. //***********************
  105. //    SetCharNum
  106. //****************************************************************************
  107. const char hexNum[] = 
  108.     { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
  109.  
  110. void CLG_CharInfo::SetCharNum( unsigned short inCharNum)
  111. {    
  112.     mCharNum = inCharNum;
  113.  
  114.     mHexStr[0]=4;
  115.  
  116.     mHexStr[1] = hexNum[ (inCharNum&0xF000) >> 12];
  117.     mHexStr[2] = hexNum[ (inCharNum&0xF00) >> 8];
  118.     mHexStr[3] = hexNum[ (inCharNum&0xF0) >> 4];
  119.     mHexStr[4] = hexNum[  inCharNum&0x0F];
  120.  
  121.     NumToString( inCharNum, mDecStr);
  122.     
  123.     Refresh();
  124. }
  125.  
  126. //***********************
  127. //    SetCurBaseChar
  128. //****************************************************************************
  129. void CLG_CharInfo::SetBaseCharDisp( unsigned short inCharNum)
  130. {    
  131.     NumToString( inCharNum, mBaseCharStr);
  132.     
  133.     Refresh();
  134. }
  135.  
  136. //***********************
  137. //    DrawSelf
  138. //****************************************************************************
  139. //  Why do I have to offset these locations?
  140.  
  141. void CLG_CharInfo::DrawSelf(void)
  142. {
  143.     SDimension16    tFrame;
  144.  
  145.     GetFrameSize( tFrame);
  146.  
  147.     PenNormal();
  148.     MoveTo( mFrameLocation.h+ 0, mFrameLocation.v+1 );
  149.     Line( tFrame.width, 0);
  150.     MoveTo( mFrameLocation.h+0, mFrameLocation.v+tFrame.height-1 );
  151.     Line( tFrame.width, 0);
  152.  
  153.     TextFont( monaco);        TextSize(9);    
  154.     TextFace(0);            TextMode( srcOr);
  155.     
  156.     MoveTo( mFrameLocation.h+2, mFrameLocation.v+12);
  157.     DrawString( "\pBase Char: ");
  158.     DrawString( "\p#");
  159.     DrawString( mBaseCharStr);    
  160.  
  161.     MoveTo( mFrameLocation.h+2, mFrameLocation.v+22);
  162.     DrawString( "\pHex:       ");
  163.     DrawString( "\p0x");
  164.     DrawString( mHexStr);    
  165.  
  166.     MoveTo( mFrameLocation.h+2, mFrameLocation.v+32);
  167.     DrawString( "\pDecimal:  ");    
  168.     DrawString( "\p #");
  169.     DrawString( mDecStr);    
  170.  
  171.     return;
  172. }
  173.  
  174. //*****************************************************************************
  175.